str = input()
count = 0
for i in range(len(str)-1):
    if str[i] == 'L':
        count += 1
        if i > 0 and str[i - 1] == 'Q' and str[i+1] == 'L':
            count += 1
print(count + 1)
